home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
pctj0587.arc
/
COMLIN.ASM
next >
Wrap
Assembly Source File
|
1987-03-19
|
2KB
|
76 lines
; Microsoft Fortran-callable function to retrieve command line data
; Copyright (C) John W. Ross 1986
; Calling format:
; N = COMLIN (COMARG)
;
; COMLIN must be declared to return an integer (short or long)
;
; N a short or long integer--the number of characters on
; the command line following the program name
;
; COMARG a CHARACTER*127 variable--the portion of the command
; line which follows the program name
; equates
psp_seg equ 4fh ; program segment prefix segment
psp_off equ 2 ; program segment prefix offset
max_len equ 127 ; length of command line data
len_off equ 80h ; offset of command line length
blank equ 20h ; blank character
cseg segment 'code' ; define the code segment
assume cs:cseg
public comlin ; make it known outside
comlin proc far
push bp ; save Fortran's registers
mov bp,sp
push ds
push ds ; point the extra segment at ds
pop es
; retrieve the number of characters on the command line
mov dx,psp_seg ; load the location of the psp
mov ds,dx ; into bx
mov bx,psp_off
mov dx,[bx]
mov ds,dx ; the psp is now the data segment
mov bx,len_off ; offset for the command line length
mov ah,0
mov al,[bx] ; command line length now in al
cmp ax,0 ; if its zero, return
je exit
; first, blank out COMARG
les bx,dword ptr[bp+6] ; the address of COMARG
xor cx,cx ; zero cx
mov cl,max_len ; set up for looping
clr: mov es:[bx],byte ptr blank
inc bx
loop clr
; now, put the actual command line data into COMARAG
les bx,dword ptr[bp+6] ; the address of COMARG
mov cx,ax ; # of characters on command line
mov si,len_off+1 ; where the command line data starts
load: mov dl,[si] ; get a character
mov es:[bx],dl ; move it to COMARG
inc bx
inc si
loop load
exit: mov dx,0 ; so we can return a long integer
pop ds ; restore Fortran's registers
mov sp,bp
pop bp
ret 4
comlin endp
cseg ends
end